package com.hzdesk.media.matvector.koreabatch.client.my_paperless.logic.view;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.hzdesk.media.matvector.koreabatch.client.my_paperless.R;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.base.BaseActivity;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.logic.contract.ILoginContract;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.logic.persenter.LoginPersenter;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.third.Eyes;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.utils.MyToastUtils;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.utils.VirtualButtonsUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class LoginActivity extends AppCompatActivity implements ILoginContract.ILoginView{

    @BindView(R.id.activity_login_et_account)
    EditText activityLoginEtAccount;
    @BindView(R.id.activity_login_et_password)
    EditText activityLoginEtPassword;
    @BindView(R.id.activity_login_iv_password)
    ImageView activityLoginIvPassword;
    @BindView(R.id.activity_login_iv_login)
    ImageView activityLoginIvLogin;
    @BindView(R.id.activity_login_tv_forget)
    TextView activityLoginTvForget;

    private LoginPersenter iLoginPersenter=new LoginPersenter(this);

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Eyes.setStatusBarColor(this, 0xffffff);
        VirtualButtonsUtils.hideNavKey(this);
        setContentView(R.layout.activity_login);
        ButterKnife.bind(this);
        iLoginPersenter.initView(activityLoginEtAccount,activityLoginEtPassword,this);
    }


    @OnClick({R.id.activity_login_iv_password, R.id.activity_login_iv_login, R.id.activity_login_tv_forget})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.activity_login_iv_password:
                iLoginPersenter.onClickedPasswordShowOrHide(activityLoginIvPassword);
                break;
            case R.id.activity_login_iv_login:
                iLoginPersenter.onClickedLogin();
                break;
            case R.id.activity_login_tv_forget:
                iLoginPersenter.onClickedForget();
                break;
        }
    }

    @Override
    public void setPasswordToShow() {

    }

    @Override
    public void setPasswordToHide() {

    }

    @Override
    public void loginSuccess() {
        Intent  intent = new Intent(this,MainActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        startActivity(intent);
    }

    @Override
    public String getAccount() {
        return activityLoginEtAccount.getText().toString().trim();
    }

    @Override
    public void setAccount(String account) {
        activityLoginEtAccount.setText(account);
    }

    @Override
    public String getPassword() {
        return activityLoginEtPassword.getText().toString().trim();
    }

    @Override
    public void setPassword(String password) {
        activityLoginEtPassword.setText(password);
    }

    @Override
    public void showMessageInfo(String message) {
        MyToastUtils.ShortToaseShow(this,message);
    }
}
